package pers.duorhs.easierfeign.config;

import lombok.Data;
import lombok.Setter;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Bean;

import java.util.ArrayList;
import java.util.List;

/**
 * @author Duorhs
 * @date 2022/1/13 8:36
 */

@ConfigurationProperties("easierfeign")
public class EasierFeignProperties {

    @Setter
    private ControllerProperties controller;

    @Setter
    private List<ClientProperties> clients;

    @Bean
    public ControllerProperties getController() {
        return null == controller ? new ControllerProperties() : controller;
    }

    @Bean
    public List<ClientProperties> getClients() {
        return null == clients ? new ArrayList<>() : clients;
    }

    @Data
    static class ControllerProperties {
        String name;
        String prefix = "";
    }

    @Data
    static class ClientProperties {
        String provider;
        String prefix = "";
    }
}
